<?php

namespace app\product\controller;

use app\common\controller\PCBase;
use app\common\controller\DBase;
use app\common\library\Upload;
use app\product\logic\ProductLogic;
use Throwable;
use  think\App;
class Product extends PCBase
{




    /**
     * 查看列表
     * @throws Throwable
     */
    public function index()
    {
        $params     = $this->request->post();
        return  (new productLogic())->getProductList($params);
    }


    /**
     * 获取详情
     * @throws Throwable
     */
    public function getInfo()
    {
        $params     = $this->request->post();
        return (new productLogic())->getInfo($params);
    }

    /**
     * 获取product_tag
     * @throws Throwable
     */
    public function getproductTag()
    {
        $params     = $this->request->post();
        return (new productLogic())->getproductTag($params);
    }



    /**
     * @desc   产品数据导入
     * @author luckyXiong
     * @date   2024-06-24
     */
    public function importInfo(){
        $file       = $this->request->file('file');
        $data       = $this->request->post();
        $type       = $data['product_type']??'';
        $res        = (new Upload($file))->upload(null, $this->getAdminId());
        (new productLogic())->importInfo($res['url'],$type);
    }



    /**
     * @desc   获取产品无限极分类接口
     * @author luckyXiong
     * @date   2024-06-29
     */
    public function getTreeList(){
        $params   = $this->request->post();
        return  (new productLogic())->getTreeList($params);
    }



    /**
     * @desc   获取产品扩展分类
     * @author luckyXiong
     * @date   2024-07-04
     */
    public function getAppendLevel(){
        $params   = $this->request->post();
        return  (new productLogic())->get_append_level($params);
    }



    /**
     * @desc   获取尺寸类型列表
     * @author luckyXiong
     * @date   2024-07-04
     */
    public function getSizeLevel(){
        $params   = $this->request->post();
        return  (new productLogic())->getSizeLevel($params);
    }


    /**
     * @desc   获取开发类型
     * @author luckyXiong
     * @date   2024-10-04
     */
    public function getDevelopType(){
        $params   = $this->request->post();
        return  (new productLogic())->getDevelopType($params);
    }



    /**
     * @desc   获取采购类型列表
     * @author luckyXiong
     * @date   2024-07-04
     */
    public function getPurchaseLevel(){
        $params   = $this->request->post();
        return  (new productLogic())->getPurchaseLevel($params);
    }



    /**
     * @desc   获取sku组合信息列表
     * @author luckyXiong
     * @date   2024-07-08
     */
    public function getSkuAttr(){
        $params   = $this->request->post();
        return  (new productLogic())->getSkuAttr($params);
    }




    /**
     * @desc   产品新增接口
     * @author luckyXiong
     * @date   2024-07-03
     */
    public function add(){
        $params   = $this->request->post();
        $params['adminId']  =  $this->getAdminId();
        return  (new productLogic())->add_product($params);
    }


    /**
     * @desc   产品编辑接口
     * @author luckyXiong
     * @date   2024-07-03
     */
    public function edit(){
        $params   = $this->request->post();
        $admin_id   = $this->getAdminId();
        $params['adminId']  = $admin_id;
        return  (new productLogic())->edit_product($params);
    }



    /**
     * @desc   产品编辑删除
     * @author luckyXiong
     * @date   2024-08-22
     */
    public function delete(){
        $params   = $this->request->post();
        $admin_id   = $this->getAdminId();
        $params['adminId']  = $admin_id;
        return  (new productLogic())->del_product($params);
    }



    /**
     * @desc   产品seller_sku组合接口
     * @author luckyXiong
     * @date   2024-07-05
     */
    public function addSellerSku(){
        $params   = $this->request->post();
        return  (new productLogic())->add_seller_sku($params);
    }

    /**
     * @desc     获取sku的子集列表
     * @author   luckyXiong
     * @date     2024-07-10
     */
    public function getSellerSkuList(){
        $params   = $this->request->post();
        return  (new productLogic())->getSellerSkuList($params);
    }

    /**
     * @desc     获取sku的子集编辑
     * @author   luckyXiong
     * @date     2024-07-10
     */
    public function editSellerSku(){
        $params   = $this->request->post();
        return  (new productLogic())->editSellerSku($params);
    }

    /**
     * @desc     sku添加颜色处理
     * @author   luckyXiong
     * @date     2024-07-11
     */
    public function addColor(){
        $params   = $this->request->post();
        return  (new productLogic())->addColor($params);
    }

    /**
     * @desc     sku删除颜色处理
     * @author   luckyXiong
     * @date     2024-07-11
     */
    public function deleteColor(){
        $params   = $this->request->post();
        return  (new productLogic())->deleteColor($params);
    }


    /**
     * @desc     获取产品属性基础分类
     * @author   luckyXiong
     * @date     2024-07-11
     */
    public function getAttrList(){
        $params   = $this->request->post();
        return  (new productLogic())->getAttrList($params);
    }


    /**
     * @desc     导出产品数据
     * @author   luckyXiong
     * @date     2024-07-18
     */
    public function exportInfo(){
        $params   = $this->request->post();
        (new productLogic())->exportInfo($params);
        return  $this->jsonMessage(200, true, '操作成功',null);
    }


    /**
     * @desc     产品数据导入消费
     * @author   luckyXiong
     * @date     2024-07-23
     */
    public function importProductConsumer(){
        $params   = $this->request->post();
        $admin_id   = $this->getAdminId();
        $params['adminId']  = $admin_id;
        $res      = (new productLogic())->importProductConsumer($params);
        return    $this->jsonMessage(200,true,'操作成功!',$res);
    }



    /**
     * @desc     查询运营角色
     * @author   luckyXiong
     * @date     2025-07-25
     */
    public function getSoleType(){
        $params              = $this->request->post();
        $params['group_id']  = $this->getAdminGroupId();
        $res        = (new productLogic())->getSoleType($params);
        return    $this->jsonMessage(200,true,'操作成功!',$res);
    }















}